from selenium import webdriver
import unittest,time
from Page.Page import Page
from Page.page1 import Page1
from data.db_a3mall import a3mall
class Testcase(unittest.TestCase):
    def setUp(self):
        self.sql = a3mall('10.59.9.12','root','yidong666','a3mall')
        self.driver = webdriver.Edge()
        self.driver.maximize_window()
    def tearDown(self):
        time.sleep(5)
        self.driver.quit()

    def test_01(self):
        po = Page(self.driver)
        po.luoji_01_login()
    def test_02(self):
        po = Page(self.driver)
        po.open_url('http://10.59.9.12:7001/')
        po.login_cl()
        yq1=po.dy1()
        self.assertEqual(yq1,'会员登录')
        po.send_name()
        po.send_pwd()
        # 强制等待输入验证码
        time.sleep(10)
        po.dl_cl()
        time.sleep(5)
        yq2=po.dy2()
        print(yq2)
        self.assertEqual(yq2,'欢迎回来，17800382574')
        yu = po.yu().replace("¥ ", "")
        print(yu)
        amount = self.sql.select('select amount from mall_users where username="17800382574"')
        amount1 = amount[0][0]
        print(amount1)
        self.assertEqual(yu, str(amount1))
    def test_03(self):
        po = Page1(self.driver)
        po.luoji_02_search()


if __name__ == '__main__':
    unittest.main()